package com.example.featuresdk.core

import com.example.featuresdk.database.DatabaseCallback
import com.example.featuresdk.model.IconManager
import com.example.featuresdk.model.User
import com.example.featuresdk.dao.UserDao
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class DatabaseInitialization @Inject constructor(private val userDao: UserDao): DatabaseCallback() {

    override suspend fun initialize() {
        //initialize users
        val users = mutableListOf<User>().apply {
            add(User.ME)
            var userId = User.ME.id!! + 1
            addAll(IconManager.icons.map { User(userId++,it.key,it.value) })
        }
        userDao.insert(users)
    }
}